package com.ff.xyh.access.controller.post;

import com.ff.xyh.access.service.post.PostShopFeignService;
import com.ff.xyh.access.service.post.PostTravelFeignService;
import com.ff.xyh.common.entity.post.PostShop;
import com.ff.xyh.common.entity.post.PostTravel;
import com.ff.xyh.common.entity.result.ResultMessage;
import com.ff.xyh.common.entity.result.ResultObject;
import com.ff.xyh.common.qo.post.PostShopQuery;
import com.ff.xyh.common.qo.post.PostTravelQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther FF
 * @Date 2023年 05月 24日
 * @Time 12:19
 */

@Api(tags = "购物帖子管理接口")
@RestController
@RequestMapping("/access/post/travel")
public class PostTravellController {

    @Autowired
    PostTravelFeignService service;

    @PostMapping("get")
    ResultObject getPostShopCondition(
            @RequestBody PostTravelQuery postTravelQuery) {
        return service.getPostTravelCondition(postTravelQuery);
    }

    @ApiOperation("修改帖子审核状态")
    @PostMapping("modify/checkStatus")
    ResultObject modifyPostCheckStatus(
            @ApiParam("传入 id 和 checkStatus")
            @RequestBody PostTravel postTravel) {
        if (postTravel.getCheckStatus().equals(0)) {
            return ResultObject.error().message(ResultMessage.ERROR_ARG);
        }
        String checkerId = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
        postTravel.setCheckerId(checkerId);
        return service.modifyPostStatus(postTravel);
    }
}